import request from '@/utils/request.js'

export function login(data) {
	return request({
		url: `auth/oauth/token`,
		method: 'POST',
		params: data,
		header: {
			'Content-Type': 'application/x-www-form-urlencoded',
			'Authorization': 'Basic YXBwOmFwcA==',
		},
	})
}

export function logout() {
	return request({
		url: `auth/token/logout`,
		method: 'DELETE',
	})
}

// 根据行政区级别获取项目聚合列表
export function aggregationList(data) {
  return request({
    url: `supervision/making/aggregationList`,
    method: 'GET',
		params: data
  })
}

//logo
export function getLogoInfo(data) {
	return request({
		url: `admin/sysLogoManage/oneLogo`,
		method: 'GET',
		params: data
	})
}
export function getLogoById(data) {
	return request({
		url: `admin/sys-file/getLogo`,
		method: 'GET',
		params: data,
		options: {
			responseType: 'arraybuffer',
		},
	})
}

//banner
export function getBanner() {
	return request({
		url: `admin/sysBannerManage/info`,
		method: 'GET',
	})
}

//应用模块菜单
export function menu(data) {
	return request({
		url: `admin/menu`,
		method: 'GET',
		params: data
	})
}

//字典
//期次
export function period() {
	return request({
		url: `admin/dict/type/period`,
		method: 'get',
	})
}
//状态
export function projectStatus() {
	return request({
		url: `business/project/projectStatus`,
		method: 'get',
	})
}
//标段
export function section() {
	return request({
		url: `admin/dict/type/section`,
		method: 'get',
	})
}
//标段
export function subItemType() {
	return request({
		url: `admin/dict/type/subItem_type`,
		method: 'get',
	})
}


//上传文件
export function upload(data) {
	return request({
		url: `admin/sys-file/upload`,
		method: 'POST',
		params: data
	})
}

//获取文件信息
export function getFileInfoAll(id) {
	return request({
		url: `admin/sys-file/getFileInfoById` + '?id=' + id,
		method: 'get',
	})
}
//返回文件路径
export function getFilePath(id) {
	return request({
		url: `admin/sys-file/getFilePath` + '?id=' + id,
		method: 'get',
	})
}
//获取文件信息
export function getFileInfo(id) {
	return request({
		url: `admin/sys-file/getFileById` + '?id=' + id,
		method: 'get',
		options: {
			responseType: 'arraybuffer',
		},
		loading: true
	})
}


//删除文件
export function delFile(id) {
	return request({
		url: `admin/sys-file/${id}`,
		method: 'DELETE',
	})
}

//通过字典类型查找字典
export function equipmentTypeAll(equipmentType) {
	return request({
		url: `admin/dict/type/`+equipmentType,
		method: 'get',
	})
}

// 获取行政区划
export function getDistrict(params) {
  return request({
    url: 'business/district/getByParentCode',
    method: 'get',
    params:params
  });
}
